﻿using System.Windows.Media;

namespace Compass.Wpf.Converters;

//true返回Gray，false返回Red
public class BoolToDeleteColorConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (value == null || !bool.TryParse(value.ToString(), out var result)) return new SolidColorBrush(Colors.Gray);
        return result? new SolidColorBrush(Colors.Gray) : new SolidColorBrush(Colors.Red);
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}
//true返回Red，false返回Black
public class BoolToRedConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (value == null || !bool.TryParse(value.ToString(), out var result)) return new SolidColorBrush(Colors.Red);
        return result ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.Black);
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}